<template>
  <div class="app-container">
    <el-card v-permission="['order:config_detail']" class="box-card">
      <el-tabs v-model="activeName">
        <el-tab-pane :label="configGroup.order.name" :id="configGroup.order.id" name="order">
          <el-form ref="configForm" :model="configForm" label-width="200px" class="margin-10">
            <el-form-item label="自动取消延时时间(秒)" prop="autoCancelTime">
              <el-input-number :precision="0" v-model="configForm.autoCancelTime" />
            </el-form-item>

            <el-form-item label="自动收货延时时间(天)" prop="autoReceivedTime">
              <el-input-number :precision="0" v-model="configForm.autoReceivedTime" />
            </el-form-item>
          </el-form>
          <div class="op-container text-center">
            <el-button v-permission="['order:config_setting']" :loading="submitIng" type="primary" @click="handleSave">保存更改</el-button>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>
<script>
import { ConfigService } from '@/api/SystemService'
import Notify from '@/utils/notify'
import { getToken } from '@/utils/auth'

export default {
  name: 'OrderConfig',
  data() {
    return {
      activeName: 'order', configForm: {}, submitIng: false, headers: { token: getToken() },
      configGroup: { order: { id: 5, name: '订单信息配置' }}
    }
  },
  created() {
    this.loadData(this.configGroup.order.id)
  },
  methods: {
    loadData(type) {
      ConfigService.getWeChatConfig(type).then(res => {
        this.configForm = res
      })
    },
    handleSave() {
      this.submitIng = true
      ConfigService.saveWeChatConfig(this.configForm).then(() => {
        Notify.success(this, '保存成功!')
        this.submitIng = false
      })
    }
  }
}
</script>
<style>
  .el-upload-list__item-name{white-space:unset;}
</style>
